package drunkensailor.framework.support;

import drunkensailor.framework.CellStates;
import java.util.ArrayList;

/**
 * Represents a space in a Map.  Contains information about contents and on which step(s) the Sailor entered this space.
 * @author William Barr
 *
 */
public class Cell {

	private CellStates state;
	private ArrayList<Integer> accesses;

	/**
	 * Creates a new Cell with the given state by default.
	 * @param state What's in this cell
	 */
	public Cell(CellStates state)
	{
		this.state = state;
		accesses = new ArrayList<Integer>();
	}
/**
 * Gets the state of this cell
 * @return The state of the cell
 */
	public CellStates getState()
	{
		return state;
	}
/**
 * Moves the sailor into the given cell and adds the turn number to the accesses ArrayList.
 * @param moveNumber The number representing the current turn to be added to the accesses ArrayList.
 */
	public void occupyCell(int moveNumber)
	{
		state = CellStates.OCCUPIED;
		accesses.add(moveNumber);
	}
/**
 * Removes the sailor from the cell and sets its state to EMPTY.
 */
	public void vacateCell()
	{
		state = CellStates.EMPTY;
	}
/**
 * Returns the ArrayList of turns on which this cell was entered by the Sailor.
 * @return The ArrayList which contains the turns.
 */
	public ArrayList<Integer> getAccesses()
	{
		return accesses;
	}
	
	public String toString()
	{
		String toRet = "Cell State:  " + state + "; ";
		for(Integer i : accesses)
			toRet+="," + i;
		return toRet;
	}
}
